var gulp = require('gulp'),
    sass = require('gulp-sass'),
    //uglify = require('gulp-uglify'),
    //minifycss = require('gulp-minify-css'),
    livereload = require('gulp-livereload'),
    postcss      = require('gulp-postcss'),
    autoprefixer = require('autoprefixer-core'),
    //babel = require('gulp-babel'),
    //browserify = require('browserify'),
    source = require('vinyl-source-stream');

//gulp.task('bundle', function() {
    //return browserify('./src/app.js')
        //.bundle()
        //.pipe(source(‘bundle.min.js))
        //.pipe(uglify())
        //.pipe(gulp.dest('dist/'));
//});

gulp.task('styles',function() {
    return gulp.src('./dev/css/*.scss')
                .pipe(sass())
                .pipe(postcss([ autoprefixer({ browsers: ['last 2 versions'] }) ]))
                .pipe(gulp.dest('./dist/css/'));
});

gulp.task('scripts',function() {
    return gulp.src('./dev/js/*.js')
                //.pipe(babel())
                //.pipe(uglify())
                .pipe(gulp.dest('./dist/js/'));
});

gulp.task('htmls',function() {
    return gulp.src('./dev/html/*.html')
                .pipe(gulp.dest('./dist/html/'));
});

gulp.task('reload', function() {
    livereload.listen();
    gulp.watch(['dev/**/**'],function(event) {
        livereload.changed(event.path);
    });
});

gulp.task('default', function() {
    gulp.start('styles', 'htmls', 'scripts');
    gulp.watch('./dev/css/*',['styles']);
    gulp.watch('./dev/html/*',['htmls']);
    gulp.watch('./dev/js/*',['scripts']);
});
